package com.bxj.common.utils;

/**
 * Created by baixiujiang on 17/12/26.
 */
public class Md5Utils {
    public static String md5(Object value) {
        return md5Str(StringUtils.toString(value, ""));
    }
    public static String md5Str(String value) {
        try {
            java.security.MessageDigest md5 = java.security.MessageDigest
                    .getInstance("MD5");
            md5.update(value.getBytes());
            StringBuilder sb = new StringBuilder();
            for (byte b : md5.digest()) {
                sb.append(String.format("%X", b));
            }
            return sb.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }

    public static void main(String[] args) {

        String md5_code = Md5Utils.md5Str("000000");
        System.out.println(md5_code);
        String md5_code1 = Md5Utils.md5Str("");
        System.out.println(md5_code1);
    }
}
